<template>
  <div>
  <el-table :data="state.dataList"
            v-loading="state.loading"
            border
            :fit="true"
            style="width:100%;height: 100%;"
            :cell-style="tableStyle.cellStyle"
            :header-cell-style="tableStyle.headerCellStyle"
  >
    <el-table-column prop="checkItemCode" :label="$t('qms.testItemCode')" show-overflow-tooltip/>
    <el-table-column prop="checkItemName" :label="$t('qms.testItem')" show-overflow-tooltip/>
    <el-table-column prop="standarditem" :label="$t('qms.standardValue')" show-overflow-tooltip/>
    <el-table-column prop="unit" :label="$t('iot.unit')" show-overflow-tooltip/>
    <el-table-column prop="testData" :label="$t('qms.testData')" show-overflow-tooltip/>
    <el-table-column prop="checkResult" :label="$t('qms.testResult')" show-overflow-tooltip>
      <template #default="scope">
        <el-tag v-if="scope.row.checkResult" :type="scope.row.checkResult == '合格\nPass' ? 'success' : 'danger'">{{ scope.row.checkResult }}</el-tag>
      </template>
    </el-table-column>
  </el-table>
  <pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination"/>
</div>
</template>

<script setup lang="ts">
import {BasicTableProps, useTable} from "/@/hooks/table";
import {getTiDPageSet} from "/@/api/platform/qms/qmsCheckReport";


// 搜索变量

const state: BasicTableProps = reactive<BasicTableProps>({
  queryForm: {},
  pageList: getTiDPageSet
})

const {
  getDataList,
  currentChangeHandle,
  sizeChangeHandle,
  tableStyle
} = useTable(state)

// 父级点击的行
const parentClickRow = {}

const clickSupportImage = (url: String) => {
  let urls = url.split(",")
  var s = encodeURIComponent(btoa(urls));
  window.open('http://172.16.100.10:8012/onlinePreview?url=' + s);
}

// 搜索变量
const queryRef = ref()

// 清空搜索条件
const resetQuery = () => {
  // 清空搜索条件
  queryRef.value?.resetFields()
  getDataList()
}

// 通过id进行子表的查询
const query = (row: Object) => {
  // 赋值查询参数
  state.queryForm.FQCId = row.id
  // 保存选中的行数据
  Object.assign(parentClickRow, row)
  // 刷新子表数据
  getDataList()
}

// 暴露变量
defineExpose({
  resetQuery,
  query,
  getDataList
});

</script>

<style scoped lang="scss">

</style>